package jp.or.kkh.yysk.springdemo2.controller;

import java.util.List;
import jp.or.kkh.yysk.springdemo2.entity.Book;
import jp.or.kkh.yysk.springdemo2.repository.BookRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

// 注释
@RestController
@RequestMapping("/books")
public class BookControl {

    @Autowired
    private BookRepository bookRepository;

    @GetMapping
    public List<Book> getAllBooks() {
        return bookRepository.findAll();
    }

    @GetMapping("/hello")
    public String hello(){
        return "Hello World";
    }

    @GetMapping("/noAnnotation")
    public Book noAnnotation(Book book){
        return book;
    }
}
